package com.cci.kangdao.controller;


import com.cci.kangdao.aop.annotation.NoDuplicateSubmission;
import com.cci.kangdao.service.CCECDiagnoseRepairMsgTService;
import com.cci.kangdao.utilTool.ParameterTool;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * ccec诊断维修信息controller
 *
 */
@Controller
public class CCECDiagnoseRepairMsgTController {
	
	private Logger log = Logger.getLogger(this.getClass().getName());

	@Autowired
	private CCECDiagnoseRepairMsgTService ccecDiagnoseRepairMsgTService;

	//ccec技师开始诊断保存和提交确认报修信息
	@NoDuplicateSubmission
	@RequestMapping("/submitAffirmRepairsMsg.aspx")
	public ModelAndView submitAffirmRepairsMsg(HttpServletRequest request,
											   HttpServletResponse response) throws Exception {
		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("response", response);
			map.put("request", request);
			return ccecDiagnoseRepairMsgTService.submitAffirmRepairsMsg(map);
		}catch(Exception ex){
			log.error(ex.getMessage(),ex);
			String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
			ParameterTool.writeResponse(response, msg);
		}
		return null;
	}


	//CCEC技师查询诊断维修详情
	@RequestMapping("/getDiagnosiResult.aspx")
	public ModelAndView getDiagnosiResult(HttpServletRequest request,
												HttpServletResponse response) throws Exception {
		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("response", response);
			map.put("request", request);
			return ccecDiagnoseRepairMsgTService.getDiagnosiResult(map);
		}catch(Exception ex){
			log.error(ex.getMessage(),ex);
			String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
			ParameterTool.writeResponse(response, msg);
		}
		return null;
	}



	//CCEC技师修改  新增诊断结果
	@NoDuplicateSubmission
	@RequestMapping("/operationDiagnosiResult.aspx")
	public ModelAndView operationDiagnosiResult(HttpServletRequest request,
												HttpServletResponse response) throws Exception {
		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("response", response);
			map.put("request", request);
			return ccecDiagnoseRepairMsgTService.operationDiagnosiResult(map);
		}catch(Exception ex){
			log.error(ex.getMessage(),ex);
			String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
			ParameterTool.writeResponse(response, msg);
		}
		return null;
	}


	//CCEC技师诊断维修   输入零件号  校验是否存在   存在返回零件相关信息
	@RequestMapping("/checkoutPartInfo.aspx")
	public ModelAndView checkoutPartInfo(HttpServletRequest request,
												HttpServletResponse response) throws Exception {
		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("response", response);
			map.put("request", request);
			return ccecDiagnoseRepairMsgTService.checkoutPartInfo(map);
		}catch(Exception ex){
			log.error(ex.getMessage(),ex);
			String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
			ParameterTool.writeResponse(response, msg);
		}
		return null;
	}


    //CCEC技师开始维修
	@NoDuplicateSubmission
	@RequestMapping("/startRepairFoCCEC.aspx")
	public ModelAndView startRepairFoCCEC(HttpServletRequest request,
										  HttpServletResponse response) throws Exception {
        try{
            Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
            map.put("response", response);
            map.put("request", request);
            return ccecDiagnoseRepairMsgTService.startRepairFoCCEC(map);
        }catch(Exception ex){
            log.error(ex.getMessage(),ex);
            String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
            ParameterTool.writeResponse(response, msg);
        }
        return null;
    }

	//ccec技师提交故障排查总结信息
	@NoDuplicateSubmission
	@RequestMapping("/submitFaultExcludeStepResult.aspx")
	public ModelAndView submitFaultExcludeStepResult(HttpServletRequest request,
													 HttpServletResponse response) throws Exception {
		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("response", response);
			map.put("request", request);
			return ccecDiagnoseRepairMsgTService.submitFaultExcludeStepResult(map);
		}catch(Exception ex){
			log.error(ex.getMessage(),ex);
			String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
			ParameterTool.writeResponse(response, msg);
		}
		return null;
	}


	//ccec技师修改确认报修信息，诊断结果信息和故障排查信息接口
	@RequestMapping("/updateCCECDiagnoseRepairMsg.aspx")
	public ModelAndView updateCCECDiagnoseRepairMsg(HttpServletRequest request,
													 HttpServletResponse response) throws Exception {
		try{
			Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
			map.put("response", response);
			map.put("request", request);
			return ccecDiagnoseRepairMsgTService.updateCCECDiagnoseRepairMsg(map);
		}catch(Exception ex){
			log.error(ex.getMessage(),ex);
			String msg = "{\"status\": -99,\"msg\": \"未知错误\"}";
			ParameterTool.writeResponse(response, msg);
		}
		return null;
	}
}
